package com.zj.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.zj.controller.AppleController;
import com.zj.mapper.TeacherMapper;
import com.zj.services.AppleService;
import com.zj.services.TeacherService;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import javax.sql.DataSource;
import java.util.Map;

@Configuration
public class BeanFactoryTest implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        //在其中调用getbean或getbeansoftype会导致该bean进行autowired属性注入失败
//        Map<String, AppleController> beans = beanFactory.getBeansOfType(AppleController.class,false,true);
//        System.out.println(beans);
//        Map<String, DruidConfig> beans2 = beanFactory.getBeansOfType(DruidConfig.class, false, false);
//        System.out.println(beans2);
//        Map<String, DruidDataSource> beans3 = beanFactory.getBeansOfType(DruidDataSource.class, false, false);
//        System.out.println(beans3);
//        Map<String, AppleService> beans4 = beanFactory.getBeansOfType(AppleService.class, false, false);
//        System.out.println(beans4);
//        Map<String, TeacherService> beans5 = beanFactory.getBeansOfType(TeacherService.class, false, false);
//        System.out.println(beans5);
//        Map<String, TeacherMapper> beans6 = beanFactory.getBeansOfType(TeacherMapper.class, false, false);
//        System.out.println(beans6);



    }

}
